package com.dudu.log.statusLog.service.impl;

import java.util.List;

import org.apache.commons.lang.StringUtils;

import net.sf.json.JSONObject;

import com.dudu.enumeration.AbilityTypeEnum;
import com.dudu.log.statusLog.dao.StatusDao;
import com.dudu.log.statusLog.service.IStatusService;

import core.CoreDao;
import core.CoreDaoInvoke;

public class StatusServiceImpl implements IStatusService {

    private CoreDao coreDao = CoreDaoInvoke.getInstance();
    private StatusDao statusDao = new StatusDao();

    /**
     * 查询条数（分页用）
     * 
     * @param paramSql
     * @return
     */
    public Integer getTotalAcount(String paramSql) {
	return statusDao.getTotalAcount(coreDao, paramSql);
    }

    /**
     * 查询数据（分页）
     * 
     * @param paramSql
     * @param pageSql
     * @return
     */
    public List<JSONObject> queryAll(String paramSql, String pageSql) {
	List<JSONObject> list = statusDao.queryAll(coreDao, paramSql, pageSql);
	if (null == list) {
	    return list;
	}
	for (JSONObject object : list) {
	    String ability_type = object.optString("vServiceType");
	    if(ability_type.equals("VoiceNotice")){
		ability_type="VOICE";
	    }
	    if(ability_type.equals("TalksV3")){
		ability_type="TalksV2";
	    }
	    AbilityTypeEnum ab=AbilityTypeEnum.getAbilityTypeEnum(ability_type);
	    String ability_typevalue="";
	    if(ab!=null){
		ability_typevalue= ab.getValue();
	    }
	    if (StringUtils.isBlank(ability_typevalue)) {
		object.put("vServiceType", ability_type);
	    } else {
		object.put("vServiceType", ability_typevalue);
	    }
	}
	return  list;
    }

}
